package com.jiayi.weiphoto.activity;



import com.jiayi.weiphoto.R;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ShareDialog extends Dialog{
	
	

	public ShareDialog(Context context, int theme) {
		super(context, theme);
		// TODO Auto-generated constructor stub
	}


	private RelativeLayout shareWeiboButton;
	private RelativeLayout shareQqButton;
	private ImageView rightButton;
	private Handler handler;
	private int dist;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.share_weibo_dialog);
		
		shareQqButton = (RelativeLayout) this.findViewById(R.id.shareQqButton);
		rightButton = (ImageView) this.findViewById(R.id.rightButton);


		

		shareQqButton.setOnClickListener(new Button.OnClickListener() {

			@Override
			public void onClick(View v) {
			//	handler.sendEmptyMessage(Constant.QQ_OAUTH);
				dismiss();
			}

		});
		shareQqButton.setOnTouchListener(new OnTouchListener() {
			boolean isContinue;

			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {
				TextView textView1 = (TextView) arg0
						.findViewById(R.id.textView1);
				final ImageView imageView = (ImageView)arg0.findViewById(R.id.imageView1);
				switch (arg1.getAction()) {
				case MotionEvent.ACTION_DOWN: {
					
					isContinue = true;
					//imageView.setImageResource(R.drawable.weibo_qq_click);
					textView1.setTextColor(Color.WHITE);
					break;
				}
				case MotionEvent.ACTION_MOVE: {
					if (isContinue) {
						final int x = (int)arg1.getX();
						final int y = (int)arg1.getY();
						if(x<-dist || x>arg0.getMeasuredWidth()+dist || y<-dist ||y>arg0.getMeasuredHeight()+dist){
							textView1.setTextColor(Color.rgb(0x66, 0x66, 0x66));
							imageView.setImageResource(R.drawable.weibo_qq_icon);
							isContinue=false;
						}
						
					}
					break;
				}
				case MotionEvent.ACTION_UP: {
					textView1.setTextColor(Color.rgb(0x66, 0x66, 0x66));
					imageView.setImageResource(R.drawable.weibo_qq_icon);
					break;
				}
				}
				return false;
			}

		});
		
		
		rightButton.setOnClickListener(new Button.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				dismiss();
			}

		});

	}
}
	


